package com.xiaocao.struts;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.xiaocao.beans.UserInfo;
import com.xiaocao.iservice.IUserInfoService;


public class UserInfoAction extends BaseAction{

	private String username;
	private String password;
	
	
	public String getUsername() {
		return username;
	}


	public void setUsername(String username) {
		this.username = username;
	}


	public String getPassword() {
		return password;
	}


	public void setPassword(String password) {
		this.password = password;
	}


	@Override
	public String execute(){
		IUserInfoService userinfoService=(IUserInfoService)this.getWebApplicationContext().getBean("userInfoService");
		if(userinfoService==null){
			return ERROR;
		}
		UserInfo  userinfo=userinfoService.getUser(username);
		if(userinfo == null){
			return ERROR;
		}
		System.out.println("ID "+userinfo.getId());
		System.out.println("Password "+userinfo.getPassword());
		@SuppressWarnings("unchecked")
		Map<String,String> session=ActionContext.getContext().getSession();
		session.put("username", username);
		return SUCCESS;
	}
}
